import logging

import requests
import responses_validator
from Tools.commos.extract import extract

def runner(k, v,my_var):
    resp = None
    match k:
        case 'request':  # 发送请求
          logging.info('1 正在发送请求')
          logging.info(f'{v}')
          my_var['resp'] =  requests.Request(**v)
        case 'response':
            logging.info('2 正在断言响应')
            logging.info(f'{v}')
            responses_validator.validator(my_var['resp'],**v)
        case 'extract':
            logging.info('3 正在提取变量')
            logging.info(f'{v}')
            for var_name, var_exp in v.items():
                value = extract(my_var['resp'],*var_exp)
                logging.info(f"{var_name} = {v}")

